-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
token based report #6216
base: main
Are you sure you want to change the base?
token based report #6216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we have a job that clears expired magic auth tokens periodically? If not, can you add one?
There is already a |
@pjain1 I responded to the two open questions on this PR. Can you let me know when you address them (or if you decide they are not worth it) and fix the merge conflict? |
type ResourceName struct { | ||
Type string | ||
Name string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use snake case for JSON field names:
type ResourceName struct { | |
Type string | |
Name string | |
} | |
type ResourceName struct { | |
Type string `json:"type"` | |
Name string `json:"name"` | |
} |
'Type', resource_type, | ||
'Name', resource_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snake case:
'Type', resource_type, | |
'Name', resource_name | |
'type', resource_type, | |
'name', resource_name |
FilterJSON string | ||
Fields []string | ||
State string | ||
DisplayName string | ||
Internal bool | ||
Resources []ResourceName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: logically it feels like Resources
should be placed here, like ResourceType
and ResourceName
were before:
FilterJSON string | |
Fields []string | |
State string | |
DisplayName string | |
Internal bool | |
Resources []ResourceName | |
Resources []ResourceName | |
FilterJSON string | |
Fields []string | |
State string | |
DisplayName string | |
Internal bool |
Filter: filter, | ||
Fields: tkn.Fields, | ||
State: tkn.State, | ||
DisplayName: tkn.DisplayName, | ||
Resources: rs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same nit:
Filter: filter, | |
Fields: tkn.Fields, | |
State: tkn.State, | |
DisplayName: tkn.DisplayName, | |
Resources: rs, | |
Resources: rs, | |
Filter: filter, | |
Fields: tkn.Fields, | |
State: tkn.State, | |
DisplayName: tkn.DisplayName, |
} | ||
|
||
externalUrls := make(map[string]*adminv1.GetReportMetaResponse_URLs, len(externalEmails)) | ||
emailTokens, err := s.reconcileMagicTokensForExternalEmails(ctx, proj.OrganizationID, proj.ID, req.Report, req.OwnerId, externalEmails) | ||
tokens, ownerEmail, err := s.createMagicTokens(ctx, proj.OrganizationID, proj.ID, req.Report, req.OwnerId, recipients, req.Resources) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a filter was applied to the report then that doesn't get propagated to the magic auth token here – so in theory, people can explore more data than that which the report filters by. Is that right? This is probably desirable in many cases, but not necessarily for external partners.
I wonder if we should perhaps add a flag to the report YAML and CreateReport
API for whether or not to generate an open URL or only an export URL. E.g. it could be named open_mode: none|full
(and then we could add support for a filtered
mode later)
if opts.Explore != "" && opts.Canvas != "" { | ||
return nil, fmt.Errorf("cannot set both explore and canvas") | ||
} | ||
res.Annotations.Explore = opts.Explore | ||
res.Annotations.Canvas = opts.Canvas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check somewhere if the report has an explore or canvas? And if not, then skip generating the open link (since it would not actually work).
Some legacy reports and YAML-managed reports may not have an explore or canvas.
// list of resources to grant access to. | ||
repeated ResourceName resources = 11; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move up above resource_type
and resource_name
@@ -49,13 +47,19 @@ func (s *Server) IssueMagicAuthToken(ctx context.Context, req *adminv1.IssueMagi | |||
return nil, status.Error(codes.PermissionDenied, "not allowed to create a magic auth token") | |||
} | |||
|
|||
resources := make([]database.ResourceName, len(req.Resources)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like it's missing backwards compatibiltiy for req.ResourceType
and req.ResourceName
? (Can be fixed by adding them to req.Resources
if they are not empty)
Changes:
UI changes needed:
email
orslack_user
query param from the url and call the unsubscribe API with this param.Important Note: This does not support locking time ranges as of now (locking dimension filter works), as they would be evaluated during each report run at runtime. The queries that are sent by explore have a separate time range apart from the filter, magic token only supports row filter. If mgc token has time range then it will need to be reconciled with the actual time range sent.
Contributes to https://github.com/orgs/rilldata/projects/38/views/8?pane=issue&itemId=85181742&issue=rilldata%7Crill-private-issues%7C855